<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test::Tutorial - A tutorial about writing really basic tests - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Test::Tutorial">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Test::Tutorial.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Test::Tutorial">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Test::Tutorial">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Test::Tutorial">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Test::Tutorial">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Test::Tutorial">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Test::Tutorial">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Test::Tutorial">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Test::Tutorial">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Test::Tutorial">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Test::Tutorial">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Test::Tutorial">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Test::Tutorial">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Test::Tutorial">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Test::Tutorial">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Test::Tutorial">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Test::Tutorial">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Test::Tutorial">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Test::Tutorial">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Test::Tutorial">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Test::Tutorial">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Test::Tutorial">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Test::Tutorial">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Test::Tutorial">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Test::Tutorial">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Test::Tutorial">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Test::Tutorial">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Test::Tutorial">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Test::Tutorial">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Test::Tutorial">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Test::Tutorial">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Test::Tutorial">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Test::Tutorial">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Test::Tutorial">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Test::Tutorial">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Test::Tutorial">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Test::Tutorial">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Test::Tutorial">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Test::Tutorial">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Test::Tutorial">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Test::Tutorial">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Test::Tutorial">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Test::Tutorial">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Test::Tutorial">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Test::Tutorial">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Test::Tutorial">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Test::Tutorial">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Test::Tutorial">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Test::Tutorial">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Test::Tutorial">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Test::Tutorial">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Test::Tutorial">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Test::Tutorial">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Test::Tutorial">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Test::Tutorial">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Test::Tutorial">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Test::Tutorial">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Test::Tutorial">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Test::Tutorial">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Test::Tutorial">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Test::Tutorial">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Test::Tutorial">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Test::Tutorial">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Test::Tutorial">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Test::Tutorial">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Test::Tutorial">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Test::Tutorial">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Test::Tutorial">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Test::Tutorial">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Test::Tutorial">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Test::Tutorial">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Test::Tutorial">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Test::Tutorial">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Test::Tutorial">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Test::Tutorial">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Test::Tutorial">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Test::Tutorial">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Test::Tutorial">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Test::Tutorial">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Test::Tutorial">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Test::Tutorial">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Test::Tutorial.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Test::Tutorial">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Test::Tutorial">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Test::Tutorial">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Test::Tutorial">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Test::Tutorial">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Test::Tutorial">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Test::Tutorial">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Test::Tutorial">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Test::Tutorial">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Test::Tutorial">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Test::Tutorial">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Test::Tutorial">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Test::Tutorial">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Test::Tutorial">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Test::Tutorial">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Test::Tutorial">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Test::Tutorial">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Test::Tutorial">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Test::Tutorial">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Test::Tutorial">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Test::Tutorial">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Test::Tutorial">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Test::Tutorial">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Test::Tutorial">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Test::Tutorial">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Test::Tutorial">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Test::Tutorial">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Test::Tutorial">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Test::Tutorial">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Test::Tutorial">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Test::Tutorial">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Test::Tutorial">5.35.1</a>
          <a class="dropdown-item active" href="./Test::Tutorial.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Test::Tutorial.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Test::Tutorial.html">Test::Tutorial</a>
          <div id="more">
            (<a href="./Test::Tutorial.txt">source</a>,
            <a href="https://metacpan.org/pod/Test::Tutorial">CPAN</a>)
          </div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#DESCRIPTION">DESCRIPTION</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Nuts-and-bolts-of-testing.">Nuts and bolts of testing.</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Where-to-start?">Where to start?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Names">Names</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Test-the-manual">Test the manual</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Sometimes-the-tests-are-wrong">Sometimes the tests are wrong</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Testing-lots-of-values">Testing lots of values</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Informative-names">Informative names</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Skipping-tests">Skipping tests</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Todo-tests">Todo tests</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#Testing-with-taint-mode.">Testing with taint mode.</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#FOOTNOTES">FOOTNOTES</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#AUTHORS">AUTHORS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#MAINTAINERS">MAINTAINERS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test::Tutorial.html#COPYRIGHT">COPYRIGHT</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Test::Tutorial.html#NAME">#</a>NAME</h1>

<p>Test::Tutorial - A tutorial about writing really basic tests</p>

<h1 id="DESCRIPTION"><a class="permalink" href="./Test::Tutorial.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p><i>AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don&#39;t make me write tests!</i></p>

<p><i>*sob*</i></p>

<p><i>Besides, I don&#39;t know how to write the damned things.</i></p>

<p>Is this you? Is writing tests right up there with writing documentation and having your fingernails pulled out? Did you open up a test and read</p>

<pre><code class="plaintext">######## We start with some black magic</code></pre>

<p>and decide that&#39;s quite enough for you?</p>

<p>It&#39;s ok. That&#39;s all gone now. We&#39;ve done all the black magic for you. And here are the tricks...</p>

<h2 id="Nuts-and-bolts-of-testing."><a class="permalink" href="./Test::Tutorial.html#Nuts-and-bolts-of-testing.">#</a><a id="Nuts"></a><a id="Nuts-and-bolts-of-testing"></a>Nuts and bolts of testing.</h2>

<p>Here&#39;s the most basic test program.</p>

<pre><code>#!/usr/bin/perl -w

print &quot;1..1\n&quot;;

print 1 + 1 == 2 ? &quot;ok 1\n&quot; : &quot;not ok 1\n&quot;;</code></pre>

<p>Because 1 + 1 is 2, it prints:</p>

<pre><code class="plaintext">1..1
ok 1</code></pre>

<p>What this says is: <code>1..1</code> &quot;I&#39;m going to run one test.&quot; [1] <code>ok 1</code> &quot;The first test passed&quot;. And that&#39;s about all magic there is to testing. Your basic unit of testing is the <i>ok</i>. For each thing you test, an <code>ok</code> is printed. Simple. <a href="./Test::Harness.html">Test::Harness</a> interprets your test results to determine if you succeeded or failed (more on that later).</p>

<p>Writing all these print statements rapidly gets tedious. Fortunately, there&#39;s <a href="./Test::Simple.html">Test::Simple</a>. It has one function, <code>ok()</code>.</p>

<pre><code>#!/usr/bin/perl -w

use Test::Simple tests =&gt; 1;

ok( 1 + 1 == 2 );</code></pre>

<p>That does the same thing as the previous code. <code>ok()</code> is the backbone of Perl testing, and we&#39;ll be using it instead of roll-your-own from here on. If <code>ok()</code> gets a true value, the test passes. False, it fails.</p>

<pre><code>#!/usr/bin/perl -w

use Test::Simple tests =&gt; 2;
ok( 1 + 1 == 2 );
ok( 2 + 2 == 5 );</code></pre>

<p>From that comes:</p>

<pre><code class="plaintext">1..2
ok 1
not ok 2
#     Failed test (test.pl at line 5)
# Looks like you failed 1 tests of 2.</code></pre>

<p><code>1..2</code> &quot;I&#39;m going to run two tests.&quot; This number is a <i>plan</i>. It helps to ensure your test program ran all the way through and didn&#39;t die or skip some tests. <code>ok 1</code> &quot;The first test passed.&quot; <code>not ok 2</code> &quot;The second test failed&quot;. Test::Simple helpfully prints out some extra commentary about your tests.</p>

<p>It&#39;s not scary. Come, hold my hand. We&#39;re going to give an example of testing a module. For our example, we&#39;ll be testing a date library, <a href="./Date::ICal.html">Date::ICal</a>. It&#39;s on CPAN, so download a copy and follow along. [2]</p>

<h2 id="Where-to-start?"><a class="permalink" href="./Test::Tutorial.html#Where-to-start?">#</a><a id="Where"></a><a id="Where-to-start"></a>Where to start?</h2>

<p>This is the hardest part of testing, where do you start? People often get overwhelmed at the apparent enormity of the task of testing a whole module. The best place to start is at the beginning. <a href="./Date::ICal.html">Date::ICal</a> is an object-oriented module, and that means you start by making an object. Test <code>new()</code>.</p>

<pre><code>#!/usr/bin/perl -w

# assume these two lines are in all subsequent examples
use strict;
use warnings;

use Test::Simple tests =&gt; 2;

use Date::ICal;

my $ical = Date::ICal-&gt;new;         # create an object
ok( defined $ical );                # check that we got something
ok( $ical-&gt;isa(&#39;Date::ICal&#39;) );     # and it&#39;s the right class</code></pre>

<p>Run that and you should get:</p>

<pre><code class="plaintext">1..2
ok 1
ok 2</code></pre>

<p>Congratulations! You&#39;ve written your first useful test.</p>

<h2 id="Names"><a class="permalink" href="./Test::Tutorial.html#Names">#</a>Names</h2>

<p>That output isn&#39;t terribly descriptive, is it? When you have two tests you can figure out which one is #2, but what if you have 102 tests?</p>

<p>Each test can be given a little descriptive name as the second argument to <code>ok()</code>.</p>

<pre><code>use Test::Simple tests =&gt; 2;

ok( defined $ical,              &#39;new() returned something&#39; );
ok( $ical-&gt;isa(&#39;Date::ICal&#39;),   &quot;  and it&#39;s the right class&quot; );</code></pre>

<p>Now you&#39;ll see:</p>

<pre><code class="plaintext">1..2
ok 1 - new() returned something
ok 2 -   and it&#39;s the right class</code></pre>

<h2 id="Test-the-manual"><a class="permalink" href="./Test::Tutorial.html#Test-the-manual">#</a><a id="Test"></a>Test the manual</h2>

<p>The simplest way to build up a decent testing suite is to just test what the manual says it does. [3] Let&#39;s pull something out of the <a href="./Date::ICal.html#SYNOPSIS">&quot;SYNOPSIS&quot; in Date::ICal</a> and test that all its bits work.</p>

<pre><code>#!/usr/bin/perl -w

use Test::Simple tests =&gt; 8;

use Date::ICal;

$ical = Date::ICal-&gt;new( year =&gt; 1964, month =&gt; 10, day =&gt; 16,
                         hour =&gt; 16,   min   =&gt; 12, sec =&gt; 47,
                         tz   =&gt; &#39;0530&#39; );

ok( defined $ical,            &#39;new() returned something&#39; );
ok( $ical-&gt;isa(&#39;Date::ICal&#39;), &quot;  and it&#39;s the right class&quot; );
ok( $ical-&gt;sec   == 47,       &#39;  sec()&#39;   );
ok( $ical-&gt;min   == 12,       &#39;  min()&#39;   );
ok( $ical-&gt;hour  == 16,       &#39;  hour()&#39;  );
ok( $ical-&gt;day   == 17,       &#39;  day()&#39;   );
ok( $ical-&gt;month == 10,       &#39;  month()&#39; );
ok( $ical-&gt;year  == 1964,     &#39;  year()&#39;  );</code></pre>

<p>Run that and you get:</p>

<pre><code class="plaintext">1..8
ok 1 - new() returned something
ok 2 -   and it&#39;s the right class
ok 3 -   sec()
ok 4 -   min()
ok 5 -   hour()
not ok 6 -   day()
#     Failed test (- at line 16)
ok 7 -   month()
ok 8 -   year()
# Looks like you failed 1 tests of 8.</code></pre>

<p>Whoops, a failure! [4] <a href="./Test::Simple.html">Test::Simple</a> helpfully lets us know on what line the failure occurred, but not much else. We were supposed to get 17, but we didn&#39;t. What did we get?? Dunno. You could re-run the test in the debugger or throw in some print statements to find out.</p>

<p>Instead, switch from <a href="./Test::Simple.html">Test::Simple</a> to <a href="./Test::More.html">Test::More</a>. <a href="./Test::More.html">Test::More</a> does everything <a href="./Test::Simple.html">Test::Simple</a> does, and more! In fact, <a href="./Test::More.html">Test::More</a> does things <i>exactly</i> the way <a href="./Test::Simple.html">Test::Simple</a> does. You can literally swap <a href="./Test::Simple.html">Test::Simple</a> out and put <a href="./Test::More.html">Test::More</a> in its place. That&#39;s just what we&#39;re going to do.</p>

<p><a href="./Test::More.html">Test::More</a> does more than <a href="./Test::Simple.html">Test::Simple</a>. The most important difference at this point is it provides more informative ways to say &quot;ok&quot;. Although you can write almost any test with a generic <code>ok()</code>, it can&#39;t tell you what went wrong. The <code>is()</code> function lets us declare that something is supposed to be the same as something else:</p>

<pre><code>use Test::More tests =&gt; 8;

use Date::ICal;

$ical = Date::ICal-&gt;new( year =&gt; 1964, month =&gt; 10, day =&gt; 16,
                         hour =&gt; 16,   min   =&gt; 12, sec =&gt; 47,
                         tz   =&gt; &#39;0530&#39; );

ok( defined $ical,            &#39;new() returned something&#39; );
ok( $ical-&gt;isa(&#39;Date::ICal&#39;), &quot;  and it&#39;s the right class&quot; );
is( $ical-&gt;sec,     47,       &#39;  sec()&#39;   );
is( $ical-&gt;min,     12,       &#39;  min()&#39;   );
is( $ical-&gt;hour,    16,       &#39;  hour()&#39;  );
is( $ical-&gt;day,     17,       &#39;  day()&#39;   );
is( $ical-&gt;month,   10,       &#39;  month()&#39; );
is( $ical-&gt;year,    1964,     &#39;  year()&#39;  );</code></pre>

<p>&quot;Is <code>$ical-&gt;sec</code> 47?&quot; &quot;Is <code>$ical-&gt;min</code> 12?&quot; With <code>is()</code> in place, you get more information:</p>

<pre><code class="plaintext">1..8
ok 1 - new() returned something
ok 2 -   and it&#39;s the right class
ok 3 -   sec()
ok 4 -   min()
ok 5 -   hour()
not ok 6 -   day()
#     Failed test (- at line 16)
#          got: &#39;16&#39;
#     expected: &#39;17&#39;
ok 7 -   month()
ok 8 -   year()
# Looks like you failed 1 tests of 8.</code></pre>

<p>Aha. <code>$ical-&gt;day</code> returned 16, but we expected 17. A quick check shows that the code is working fine, we made a mistake when writing the tests. Change it to:</p>

<pre><code>is( $ical-&gt;day,     16,       &#39;  day()&#39;   );</code></pre>

<p>... and everything works.</p>

<p>Any time you&#39;re doing a &quot;this equals that&quot; sort of test, use <code>is()</code>. It even works on arrays. The test is always in scalar context, so you can test how many elements are in an array this way. [5]</p>

<pre><code>is( @foo, 5, &#39;foo has 5 elements&#39; );</code></pre>

<h2 id="Sometimes-the-tests-are-wrong"><a class="permalink" href="./Test::Tutorial.html#Sometimes-the-tests-are-wrong">#</a><a id="Sometimes"></a>Sometimes the tests are wrong</h2>

<p>This brings up a very important lesson. Code has bugs. Tests are code. Ergo, tests have bugs. A failing test could mean a bug in the code, but don&#39;t discount the possibility that the test is wrong.</p>

<p>On the flip side, don&#39;t be tempted to prematurely declare a test incorrect just because you&#39;re having trouble finding the bug. Invalidating a test isn&#39;t something to be taken lightly, and don&#39;t use it as a cop out to avoid work.</p>

<h2 id="Testing-lots-of-values"><a class="permalink" href="./Test::Tutorial.html#Testing-lots-of-values">#</a><a id="Testing"></a>Testing lots of values</h2>

<p>We&#39;re going to be wanting to test a lot of dates here, trying to trick the code with lots of different edge cases. Does it work before 1970? After 2038? Before 1904? Do years after 10,000 give it trouble? Does it get leap years right? We could keep repeating the code above, or we could set up a little try/expect loop.</p>

<pre><code>use Test::More tests =&gt; 32;
use Date::ICal;

my %ICal_Dates = (
        # An ICal string     And the year, month, day
        #                    hour, minute and second we expect.
        &#39;19971024T120000&#39; =&gt;    # from the docs.
                            [ 1997, 10, 24, 12,  0,  0 ],
        &#39;20390123T232832&#39; =&gt;    # after the Unix epoch
                            [ 2039,  1, 23, 23, 28, 32 ],
        &#39;19671225T000000&#39; =&gt;    # before the Unix epoch
                            [ 1967, 12, 25,  0,  0,  0 ],
        &#39;18990505T232323&#39; =&gt;    # before the MacOS epoch
                            [ 1899,  5,  5, 23, 23, 23 ],
);


while( my($ical_str, $expect) = each %ICal_Dates ) {
    my $ical = Date::ICal-&gt;new( ical =&gt; $ical_str );

    ok( defined $ical,            &quot;new(ical =&gt; &#39;$ical_str&#39;)&quot; );
    ok( $ical-&gt;isa(&#39;Date::ICal&#39;), &quot;  and it&#39;s the right class&quot; );

    is( $ical-&gt;year,    $expect-&gt;[0],     &#39;  year()&#39;  );
    is( $ical-&gt;month,   $expect-&gt;[1],     &#39;  month()&#39; );
    is( $ical-&gt;day,     $expect-&gt;[2],     &#39;  day()&#39;   );
    is( $ical-&gt;hour,    $expect-&gt;[3],     &#39;  hour()&#39;  );
    is( $ical-&gt;min,     $expect-&gt;[4],     &#39;  min()&#39;   );
    is( $ical-&gt;sec,     $expect-&gt;[5],     &#39;  sec()&#39;   );
}</code></pre>

<p>Now we can test bunches of dates by just adding them to <code>%ICal_Dates</code>. Now that it&#39;s less work to test with more dates, you&#39;ll be inclined to just throw more in as you think of them. Only problem is, every time we add to that we have to keep adjusting the <code>use Test::More tests =&gt; ##</code> line. That can rapidly get annoying. There are ways to make this work better.</p>

<p>First, we can calculate the plan dynamically using the <code>plan()</code> function.</p>

<pre><code>use Test::More;
use Date::ICal;

my %ICal_Dates = (
    ...same as before...
);

# For each key in the hash we&#39;re running 8 tests.
plan tests =&gt; keys(%ICal_Dates) * 8;

...and then your tests...</code></pre>

<p>To be even more flexible, use <code>done_testing</code>. This means we&#39;re just running some tests, don&#39;t know how many. [6]</p>

<pre><code>use Test::More;   # instead of tests =&gt; 32

... # tests here

done_testing();   # reached the end safely</code></pre>

<p>If you don&#39;t specify a plan, <a href="./Test::More.html">Test::More</a> expects to see <code>done_testing()</code> before your program exits. It will warn you if you forget it. You can give <code>done_testing()</code> an optional number of tests you expected to run, and if the number ran differs, <a href="./Test::More.html">Test::More</a> will give you another kind of warning.</p>

<h2 id="Informative-names"><a class="permalink" href="./Test::Tutorial.html#Informative-names">#</a><a id="Informative"></a>Informative names</h2>

<p>Take a look at the line:</p>

<pre><code>ok( defined $ical,            &quot;new(ical =&gt; &#39;$ical_str&#39;)&quot; );</code></pre>

<p>We&#39;ve added more detail about what we&#39;re testing and the ICal string itself we&#39;re trying out to the name. So you get results like:</p>

<pre><code class="plaintext">ok 25 - new(ical =&gt; &#39;19971024T120000&#39;)
ok 26 -   and it&#39;s the right class
ok 27 -   year()
ok 28 -   month()
ok 29 -   day()
ok 30 -   hour()
ok 31 -   min()
ok 32 -   sec()</code></pre>

<p>If something in there fails, you&#39;ll know which one it was and that will make tracking down the problem easier. Try to put a bit of debugging information into the test names.</p>

<p>Describe what the tests test, to make debugging a failed test easier for you or for the next person who runs your test.</p>

<h2 id="Skipping-tests"><a class="permalink" href="./Test::Tutorial.html#Skipping-tests">#</a><a id="Skipping"></a>Skipping tests</h2>

<p>Poking around in the existing <a href="./Date::ICal.html">Date::ICal</a> tests, I found this in <i>t/01sanity.t</i> [7]</p>

<pre><code>#!/usr/bin/perl -w

use Test::More tests =&gt; 7;
use Date::ICal;

# Make sure epoch time is being handled sanely.
my $t1 = Date::ICal-&gt;new( epoch =&gt; 0 );
is( $t1-&gt;epoch, 0,          &quot;Epoch time of 0&quot; );

# XXX This will only work on unix systems.
is( $t1-&gt;ical, &#39;19700101Z&#39;, &quot;  epoch to ical&quot; );

is( $t1-&gt;year,  1970,       &quot;  year()&quot;  );
is( $t1-&gt;month, 1,          &quot;  month()&quot; );
is( $t1-&gt;day,   1,          &quot;  day()&quot;   );

# like the tests above, but starting with ical instead of epoch
my $t2 = Date::ICal-&gt;new( ical =&gt; &#39;19700101Z&#39; );
is( $t2-&gt;ical, &#39;19700101Z&#39;, &quot;Start of epoch in ICal notation&quot; );

is( $t2-&gt;epoch, 0,          &quot;  and back to ICal&quot; );</code></pre>

<p>The beginning of the epoch is different on most non-Unix operating systems [8]. Even though Perl smooths out the differences for the most part, certain ports do it differently. MacPerl is one off the top of my head. [9] Rather than putting a comment in the test and hoping someone will read the test while debugging the failure, we can explicitly say it&#39;s never going to work and skip the test.</p>

<pre><code>use Test::More tests =&gt; 7;
use Date::ICal;

# Make sure epoch time is being handled sanely.
my $t1 = Date::ICal-&gt;new( epoch =&gt; 0 );
is( $t1-&gt;epoch, 0,          &quot;Epoch time of 0&quot; );

SKIP: {
    skip(&#39;epoch to ICal not working on Mac OS&#39;, 6)
        if $^O eq &#39;MacOS&#39;;

    is( $t1-&gt;ical, &#39;19700101Z&#39;, &quot;  epoch to ical&quot; );

    is( $t1-&gt;year,  1970,       &quot;  year()&quot;  );
    is( $t1-&gt;month, 1,          &quot;  month()&quot; );
    is( $t1-&gt;day,   1,          &quot;  day()&quot;   );

    # like the tests above, but starting with ical instead of epoch
    my $t2 = Date::ICal-&gt;new( ical =&gt; &#39;19700101Z&#39; );
    is( $t2-&gt;ical, &#39;19700101Z&#39;, &quot;Start of epoch in ICal notation&quot; );

    is( $t2-&gt;epoch, 0,          &quot;  and back to ICal&quot; );
}</code></pre>

<p>A little bit of magic happens here. When running on anything but MacOS, all the tests run normally. But when on MacOS, <code>skip()</code> causes the entire contents of the SKIP block to be jumped over. It never runs. Instead, <code>skip()</code> prints special output that tells <a href="./Test::Harness.html">Test::Harness</a> that the tests have been skipped.</p>

<pre><code class="plaintext">1..7
ok 1 - Epoch time of 0
ok 2 # skip epoch to ICal not working on MacOS
ok 3 # skip epoch to ICal not working on MacOS
ok 4 # skip epoch to ICal not working on MacOS
ok 5 # skip epoch to ICal not working on MacOS
ok 6 # skip epoch to ICal not working on MacOS
ok 7 # skip epoch to ICal not working on MacOS</code></pre>

<p>This means your tests won&#39;t fail on MacOS. This means fewer emails from MacPerl users telling you about failing tests that you know will never work. You&#39;ve got to be careful with skip tests. These are for tests which don&#39;t work and <i>never will</i>. It is not for skipping genuine bugs (we&#39;ll get to that in a moment).</p>

<p>The tests are wholly and completely skipped. [10] This will work.</p>

<pre><code>SKIP: {
    skip(&quot;I don&#39;t wanna die!&quot;);

    die, die, die, die, die;
}</code></pre>

<h2 id="Todo-tests"><a class="permalink" href="./Test::Tutorial.html#Todo-tests">#</a><a id="Todo"></a>Todo tests</h2>

<p>While thumbing through the <a href="./Date::ICal.html">Date::ICal</a> man page, I came across this:</p>

<pre><code>ical

    $ical_string = $ical-&gt;ical;

Retrieves, or sets, the date on the object, using any
valid ICal date/time string.</code></pre>

<p>&quot;Retrieves or sets&quot;. Hmmm. I didn&#39;t see a test for using <code>ical()</code> to set the date in the Date::ICal test suite. So I wrote one:</p>

<pre><code>use Test::More tests =&gt; 1;
use Date::ICal;

my $ical = Date::ICal-&gt;new;
$ical-&gt;ical(&#39;20201231Z&#39;);
is( $ical-&gt;ical, &#39;20201231Z&#39;,   &#39;Setting via ical()&#39; );</code></pre>

<p>Run that. I saw:</p>

<pre><code class="plaintext">1..1
not ok 1 - Setting via ical()
#     Failed test (- at line 6)
#          got: &#39;20010814T233649Z&#39;
#     expected: &#39;20201231Z&#39;
# Looks like you failed 1 tests of 1.</code></pre>

<p>Whoops! Looks like it&#39;s unimplemented. Assume you don&#39;t have the time to fix this. [11] Normally, you&#39;d just comment out the test and put a note in a todo list somewhere. Instead, explicitly state &quot;this test will fail&quot; by wrapping it in a <code>TODO</code> block:</p>

<pre><code>use Test::More tests =&gt; 1;

TODO: {
    local $TODO = &#39;ical($ical) not yet implemented&#39;;

    my $ical = Date::ICal-&gt;new;
    $ical-&gt;ical(&#39;20201231Z&#39;);

    is( $ical-&gt;ical, &#39;20201231Z&#39;,   &#39;Setting via ical()&#39; );
}</code></pre>

<p>Now when you run, it&#39;s a little different:</p>

<pre><code>1..1
not ok 1 - Setting via ical() # TODO ical($ical) not yet implemented
#          got: &#39;20010822T201551Z&#39;
#     expected: &#39;20201231Z&#39;</code></pre>

<p><a href="./Test::More.html">Test::More</a> doesn&#39;t say &quot;Looks like you failed 1 tests of 1&quot;. That &#39;# TODO&#39; tells <a href="./Test::Harness.html">Test::Harness</a> &quot;this is supposed to fail&quot; and it treats a failure as a successful test. You can write tests even before you&#39;ve fixed the underlying code.</p>

<p>If a TODO test passes, <a href="./Test::Harness.html">Test::Harness</a> will report it &quot;UNEXPECTEDLY SUCCEEDED&quot;. When that happens, remove the TODO block with <code>local $TODO</code> and turn it into a real test.</p>

<h2 id="Testing-with-taint-mode."><a class="permalink" href="./Test::Tutorial.html#Testing-with-taint-mode.">#</a><a id="Testing1"></a><a id="Testing-with-taint-mode"></a>Testing with taint mode.</h2>

<p>Taint mode is a funny thing. It&#39;s the globalest of all global features. Once you turn it on, it affects <i>all</i> code in your program and <i>all</i> modules used (and all the modules they use). If a single piece of code isn&#39;t taint clean, the whole thing explodes. With that in mind, it&#39;s very important to ensure your module works under taint mode.</p>

<p>It&#39;s very simple to have your tests run under taint mode. Just throw a <code>-T</code> into the <code>#!</code> line. <a href="./Test::Harness.html">Test::Harness</a> will read the switches in <code>#!</code> and use them to run your tests.</p>

<pre><code class="plaintext">#!/usr/bin/perl -Tw

...test normally here...</code></pre>

<p>When you say <code>make test</code> it will run with taint mode on.</p>

<h1 id="FOOTNOTES"><a class="permalink" href="./Test::Tutorial.html#FOOTNOTES">#</a>FOOTNOTES</h1>

<ol>

<li><p>The first number doesn&#39;t really mean anything, but it has to be 1. It&#39;s the second number that&#39;s important.</p>

</li>
<li><p>For those following along at home, I&#39;m using version 1.31. It has some bugs, which is good -- we&#39;ll uncover them with our tests.</p>

</li>
<li><p>You can actually take this one step further and test the manual itself. Have a look at <a href="./Test::Inline.html">Test::Inline</a> (formerly <a href="./Pod::Tests.html">Pod::Tests</a>).</p>

</li>
<li><p>Yes, there&#39;s a mistake in the test suite. What! Me, contrived?</p>

</li>
<li><p>We&#39;ll get to testing the contents of lists later.</p>

</li>
<li><p>But what happens if your test program dies halfway through?! Since we didn&#39;t say how many tests we&#39;re going to run, how can we know it failed? No problem, <a href="./Test::More.html">Test::More</a> employs some magic to catch that death and turn the test into a failure, even if every test passed up to that point.</p>

</li>
<li><p>I cleaned it up a little.</p>

</li>
<li><p>Most Operating Systems record time as the number of seconds since a certain date. This date is the beginning of the epoch. Unix&#39;s starts at midnight January 1st, 1970 GMT.</p>

</li>
<li><p>MacOS&#39;s epoch is midnight January 1st, 1904. VMS&#39;s is midnight, November 17th, 1858, but vmsperl emulates the Unix epoch so it&#39;s not a problem.</p>

</li>
<li><p>As long as the code inside the SKIP block at least compiles. Please don&#39;t ask how. No, it&#39;s not a filter.</p>

</li>
<li><p>Do NOT be tempted to use TODO tests as a way to avoid fixing simple bugs!</p>

</li>
</ol>

<h1 id="AUTHORS"><a class="permalink" href="./Test::Tutorial.html#AUTHORS">#</a>AUTHORS</h1>

<p>Michael G Schwern &lt;schwern@pobox.com&gt; and the perl-qa dancers!</p>

<h1 id="MAINTAINERS"><a class="permalink" href="./Test::Tutorial.html#MAINTAINERS">#</a>MAINTAINERS</h1>

<dl>

<dt id="Chad-Granum"><a class="permalink" href="./Test::Tutorial.html#Chad-Granum">#</a><a id="Chad-Granum-&lt;exodist@cpan.org&gt;"></a><a id="Chad"></a><a id="Chad-Granum-exodist-cpan.org"></a>Chad Granum &lt;exodist@cpan.org&gt;</dt>
<dd>

</dd>
</dl>

<h1 id="COPYRIGHT"><a class="permalink" href="./Test::Tutorial.html#COPYRIGHT">#</a>COPYRIGHT</h1>

<p>Copyright 2001 by Michael G Schwern &lt;schwern@pobox.com&gt;.</p>

<p>This documentation is free; you can redistribute it and/or modify it under the same terms as Perl itself.</p>

<p>Irrespective of its distribution, all code examples in these files are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required.</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
